package com.sws.web.controller.student_attendance.capture;

import com.sws.capture.domain.CapRecord;
import com.sws.capture.service.CapRecordService;
import com.sws.common.annotation.Log;
import com.sws.common.core.controller.BaseController;
import com.sws.common.core.domain.AjaxResult;
import com.sws.common.core.page.TableDataInfo;
import com.sws.common.enums.BusinessType;
import com.sws.common.utils.poi.ExcelUtil;
import com.sws.device.domain.DevDevice;
import com.sws.device.mapper.DevDeviceMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;


@Api(tags = {"设备管理模块"})
@RestController
@RequestMapping("/student/capture/capture")
public class CapController extends BaseController {

    @Autowired
    private CapRecordService capRecordService;
    
    @Autowired
    private DevDeviceMapper devDeviceMapper;

    /**
     * 查询人脸抓拍记录列表
     */
    @ApiOperation("查询人脸抓拍记录列表")
    @PreAuthorize("@ss.hasPermi('capture:capture:list')")
    @GetMapping("/list")
    public TableDataInfo list(CapRecord capRecord)
    {
        startPage();
        List<CapRecord> list = capRecordService.selectCapRecordList(capRecord);
        return getDataTable(list);
    }

    /**
     * 导出人脸抓拍记录列表
     */
    @ApiOperation("导出人脸抓拍记录列表")
    @PreAuthorize("@ss.hasPermi('capture:capture:export')")
    @Log(title = "人脸抓拍记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CapRecord capRecord)
    {
        List<CapRecord> list = capRecordService.selectCapRecordList(capRecord);
        ExcelUtil<CapRecord> util = new ExcelUtil<CapRecord>(CapRecord.class);
        util.exportExcel(response, list, "人脸抓拍记录数据");
    }

    /**
     * 获取人脸抓拍记录详细信息
     */
    @ApiOperation("获取人脸抓拍记录详细信息")
    @PreAuthorize("@ss.hasPermi('capture:capture:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(capRecordService.selectCapRecordById(id));
    }

    /**
     * 新增人脸抓拍记录
     */
    @ApiOperation("新增人脸抓拍记录")
    @PreAuthorize("@ss.hasPermi('capture:capture:add')")
    @Log(title = "人脸抓拍记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CapRecord capRecord)
    {
        return toAjax(capRecordService.insertCapRecord(capRecord));
    }

    /**
     * 修改人脸抓拍记录
     */
    @ApiOperation("修改人脸抓拍记录")
    @PreAuthorize("@ss.hasPermi('capture:capture:edit')")
    @Log(title = "人脸抓拍记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CapRecord capRecord)
    {
        return toAjax(capRecordService.updateCapRecord(capRecord));
    }

    /**
     * 删除人脸抓拍记录
     */
    @ApiOperation("删除人脸抓拍记录")
    @PreAuthorize("@ss.hasPermi('capture:capture:remove')")
    @Log(title = "人脸抓拍记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(capRecordService.deleteCapRecordByIds(ids));
    }

}
